<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //数组解构
    let arr = [1,2,3];
    // let a = arr[0];
    // let b = arr[1];
    // let c = arr[2];
    let [a,b,c] =arr;
    console.log(a,b,c)

    //对象解构
    const person = {
        name: "jack",
        age: 21,
        language:['java','c',"python"]
    }
    // const name = person.name;
    // const age = person.age;
    // const language = person.language;
    // const {name,age,language} = person
    // console.log(name,age,language)

    //如果先将值赋给其他变量,如下：copyname是新的变量名
    const {name:copyname,age,language} = person
    console.log(copyname,age,language)

    //字符串扩展
    let str = "hello";
    console.log(str.startsWith("hell")) //true
    console.log(str.endsWith("llo"))    //true
    console.log(str.includes("l"))      //true
    console.log(str.includes("hello"))  //true

    //字符串模板
    let ss = `<div>
                <span>hello world<span>
            </div>`;
    console.log(ss);

    // 字符串插入变量和表达式。变量名写在 ${} 中，${} 中可以放入 JavaScript 表达式。
    function fun(){
        return "hello"
    }
    let info = `我是${copyname}，今年${age + 10}了, 我想说： ${fun()}`;
    console.log(info);
</script>
</html>